package leetcode;

/**
 * @program: datastructureandalogorithm
 * @description:
 * @author: hmx
 * @create: 2022-02-27 21:08
 **/
public class LeetCode533 {

    public String optimalDivision(int[] nums) {
        int n = nums.length;
        if (n == 1) {
            return String.valueOf(nums[0]);
        } else if (n == 2) {
            return String.valueOf(nums[0] + "/" + nums[1]);
        }
        StringBuilder ans = new StringBuilder();
        ans.append(nums[0]).append("/(").append(nums[1]);
        for (int i = 2; i < n; ++i) {
            ans.append('/').append(nums[i]);
        }
        ans.append(')');
        return ans.toString();
    }

}
